package com.itheima.demo01.File;


import java.io.File;

public class Demo03File {
    public static void main(String[] args) {
//        show01();
//        show02();
//        show03();
        show04();
    }

    public static void show01() {
        File f1 = new File("D:\\Java-Code\\day08_FileAndRecursion\\a.txt");
        String absolutePath1 = f1.getAbsolutePath();
        System.out.println(absolutePath1);
        File f2 = new File("day08_FileAndRecursion\\a.txt");
        String absolutePath2 = f2.getAbsolutePath();
        System.out.println(absolutePath2);
    }

    public static void show02() {
        File f1 = new File("D:\\Java-Code\\day08_FileAndRecursion\\a.txt");
        String path1 = f1.getPath();
        System.out.println(path1);
        File f2 = new File("day08_FileAndRecursion\\a.txt");
        String path2 = f2.getPath();
        System.out.println(path2);
        System.out.println(f2);//默认调用toString方法，它再调用getPath方法
    }

    public static void show03() {
        File f1 = new File("D:\\Java-Code\\day08_FileAndRecursion\\a.txt");
        String name1 = f1.getName();
        System.out.println(name1);
        File f2 = new File("D:\\Java-Code\\day08_FileAndRecursion");
        String name2 = f2.getName();
        System.out.println(name2);
    }

    public static void show04() {
        File f1=new File("D:\\Java-Code\\day08_FileAndRecursion\\1.jpg");
        long l1 = f1.length();
        System.out.println(l1);
        File f2=new File("D:\\Java-Code\\day08_FileAndRecursion\\2.jpg");
        long l2 = f2.length();
        System.out.println(l2);
        File f3=new File("D:\\Java-Code\\day08_FileAndRecursion");
        long l3 = f3.length();
        System.out.println(l3);
    }
}
